import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
import { ZhimaService } from './zhima.service';
import { CreateZhimaDto } from './dto/create-zhima.dto';
import { UpdateZhimaDto } from './dto/update-zhima.dto';
import { ApiBearerAuth, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';

@ApiBearerAuth()
@ApiTags('芝麻管理')
@Controller('zhima')
export class ZhimaController {
  constructor(private readonly zhimaService: ZhimaService) {}

  @Post()
  @ApiOperation({ summary: '新增', description: '新增' })
  create(@Body() createZhimaDto: CreateZhimaDto) {
    return this.zhimaService.create(createZhimaDto);
  }

  @Get()
  @ApiOperation({ summary: '查询', description: '查询' })
  @ApiQuery({ name: 'pageNum', type: Number, required: false, description: '页码' })
  @ApiQuery({ name: 'pageSize', type: Number, required: false, description: '每页几条' })
  findAll(@Query() params: any) {
    return this.zhimaService.findAll(params);
  }

  @Get(':name')
  @ApiOperation({ summary: '详情', description: '详情' })
  findOne(@Param('name') name: string) {
    return this.zhimaService.findOne(name);
  }

  @Post('edit')
  @ApiOperation({ summary: '修改', description: '修改' })
  edit(@Body() createZhimaDto: CreateZhimaDto) {
    return this.zhimaService.edit(createZhimaDto);
  }
}
